package com.atguigu.educms.service.impl;

import com.atguigu.educms.pojo.CrmBanner;
import com.atguigu.educms.mapper.CrmBannerMapper;
import com.atguigu.educms.service.CrmBannerService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-11-25
 */
@Service
//构成属性名字
@Cacheable(key = "'selectIndexList'",value = "banner")
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

    @Override
    public List<CrmBanner> selectAllbanner() {
        //根据id进行降序的排列，显示排列之后的两条记录
        QueryWrapper<CrmBanner> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");//显示前两条记录
        //有一个方法，拼接sql语句
        queryWrapper.last("limit 0,2");
        List<CrmBanner> crmBanners = baseMapper.selectList(queryWrapper);

        return crmBanners ;
    }

}
